#! /usr/bin/make

PACKAGE = retro8
VERSION = 0.0.0

CXXFLAGS = -std=c++0x -Wall -g -O2

prefix = $(DESTDIR)/usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
includedir = $(prefix)/include/R8B
libdir = $(exec_prefix)/lib
localstatedir = $(prefix)/var
datarootdir = $(prefix)/share
datadir = $(datarootdir)/$(PACKAGE)

OBJ = tiles.o sprite.o
INC = tiles.h sprite.h

.PHONY: all clean examples install uninstall

all:	libretro8.a basic framebasic

framebasic: bV2.o framebasic.o
	$(CXX) $(CXXFLAGS) -o $@ $+ -lSDL -lSGE

basic: bV2.o basicV1_5.o
	$(CXX) $(CXXFLAGS) -o $@ $+

libretro8.a:	$(OBJ)
	ar rcs libretro8.a $+

clean:
	rm -f *.o *.hi *.a retro8Test *.x

install:
	install -d $(includedir) $(libdir) $(datadir)
	cp libretro8.a $(libdir)
	cp $(INC) $(includedir)
	cp *.xpm $(datadir)

uninstall:
	rm -r $(datadir)
	rm -r $(includedir)
	rm $(libdir)/libretro8.a

examples.a:	milkrace.o
	ar rcs $@ $+

examples: examples.a example.1.x example.2.x

%.x:	%.o examples.a libretro8.a
	g++ $(CCFLAGS) -o $@ $< examples.a libretro8.a -lSDL -lSDL_image -lSDL_gfx

